package moe.fuqiuluo.api

import moe.fuqiuluo.unidbg.session.Session
import moe.fuqiuluo.unidbg.session.SessionManager

fun findSession(uin: Long): Session {
    return SessionManager[uin] ?: throw SessionNotFoundError
}

internal inline fun <T> Session.withLock(block: () -> T): T {
    try{
        lock.lock()
        return block()
    }finally {
        lock.unlock()
    }
}